window.onload = function(){
    loadGrade()
}
// 加载年级信息
function loadGrade(){
    let xhr = new XMLHttpRequest()
    /* 
        https://www.bingjs.com:8001/Grade/GetAll  查询全部年级信息  [GET请求]
    */
    xhr.open("GET",`https://www.bingjs.com:8001/Grade/GetAll`)
    xhr.send()
    xhr.onreadystatechange = function(){
        if(xhr.readyState === 4 && xhr.status === 200){
            let str = JSON.parse(xhr.response)
            console.log(str)
            str.forEach(a=>{
                let tr = document.createElement("tr")
                // 年级编号
                let td_gradeId = document.createElement("td")
                td_gradeId.innerHTML = a.GradeId
                // 年级名称
                let td_gradeName = document.createElement("td")
                td_gradeName.innerHTML = a.GradeName
                
                tr.appendChild(td_gradeId)
                tr.appendChild(td_gradeName)
                
                tbody.appendChild(tr)
            })
        }
    }
}